package com.mapapp.flutter_mapapp.widget;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.view.View;

import com.mapapp.flutter_mapapp.R;

import razerdp.basepopup.BasePopupWindow;

public class NewTaskConfirmDialog extends BasePopupWindow {

    private CardView cvOk;
    private CardView cvCancel;


    public NewTaskConfirmDialog(Context context) {
        super(context);
        init();
    }

    @Override
    public View onCreateContentView() {
        View view = createPopupById(R.layout.dialog_new_task_confirm);
        cvOk = view.findViewById(R.id.cv_ok);
        cvCancel = view.findViewById(R.id.cv_cancel);
        return view;
    }

    private void init() {
        cvOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onClick(1);
                }
                dismiss();
            }
        });

        cvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onClick(2);
                }
                dismiss();
            }
        });
    }

    public interface OnEnsureClickListener {
        void onClick(int state);
    }

    private OnEnsureClickListener listener;

    public void setListener(OnEnsureClickListener listener) {
        this.listener = listener;
    }
}
